package com.lenovo.agricultureclient.request;

import org.json.JSONException;
import org.json.JSONObject;

import com.lenovo.agricultureclient.util.Util;
/**
 * 用户注册请求类
 * @author zongbingwu
 *
 */
public class RegisterRequest extends AgricultureRequest 
{
	//action name
	private static final String ACTION = "register"; 
	
	private String username;
	private String password;
	private String email;

	@Override
	protected String getActionName() {
		return ACTION;
	}
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

	//jason协议时的获取body函数
	@Override
	protected String onGetJasonBody() 
	{
		JSONObject jsonObj = new JSONObject();
		try 
		{
			jsonObj.put("username", username);//用户名
			jsonObj.put("password", password);//密码
			jsonObj.put("email", email);//邮箱
			return jsonObj.toString();
		} 
		catch (JSONException e) {
			e.printStackTrace();
		}
		return super.onGetJasonBody();
	}
	
	//soap协议时的获取body函数
	@Override
	protected String onGetSoapBody() 
	{
		String soapBody = Util.getXmlElementStr("username", username);//用户名
		soapBody += Util.getXmlElementStr("password", password);//密码
		soapBody += Util.getXmlElementStr("email", email);//邮箱
		return Util.getSoapXml(soapBody);
	}

}
